package com.salon.modules.app.controller;

import com.salon.common.http.response.ObjectResult;
import com.salon.modules.app.annotation.Login;
import com.salon.modules.app.annotation.LoginUser;
import com.salon.modules.makeup.entity.UserEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * APP测试接口
 */
@RestController
@RequestMapping("/app")
@Api(tags = "测试接口")
public class TestController {

    @Login
    @GetMapping("userInfo")
    @ApiOperation("获取用户信息")
    public ObjectResult<UserEntity> userInfo(@LoginUser UserEntity user) {
        return ObjectResult.success(user);
    }

    @Login
    @GetMapping("userId")
    @ApiOperation("获取用户ID")
    public ObjectResult<Integer> userInfo(@RequestAttribute("userId") Integer userId) {
        return ObjectResult.success(userId);
    }

    @GetMapping("notToken")
    @ApiOperation("忽略Token验证")
    public ObjectResult<String> notToken() {
        return ObjectResult.success("无需token也能访问");
    }

}
